Change in openvpn[master]: Enable key export with mbed TLS 3.x.y
A message that is not in the archive (sent off-list or not yet received): gerrit.1699630545000.I8e90530726b7f7ba3cee0438f2d81a1ac42e821b@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
to review the following change.
Change subject: Enable key export with mbed TLS 3.x.y
......................................................................
Enable key export with mbed TLS 3.x.y
---
M config.h.cmake.in
M configure.ac
M src/openvpn/Makefile.am
M src/openvpn/crypto_mbedtls.c
M src/openvpn/mbedtls_compat.h
M src/openvpn/ssl_mbedtls.c
6 files changed, 83 insertions(+), 21 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/02/402/1
config.h.cmake.in +4 -1
@@ -387,7 +387,10 @@ #undef HAVE_VSNPRINTF /* we always assume a recent mbed TLS version */ -#define HAVE_CTR_DRBG_UPDATE_RET 1 +#define HAVE_MBEDTLS_PSA_CRYPTO_H 1 +#define HAVE_MBEDTLS_SSL_TLS_PRF 1 +#define HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB 1 +#define HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET 1 /* Path to ifconfig tool */ #define IFCONFIG_PATH "@IFCONFIG_PATH@"
configure.ac +24 -8
@@ -1025,11 +1025,11 @@ [AC_MSG_ERROR([mbed TLS version >= 2.0.0 or >= 3.2.1 required])] ) - AC_CHECK_HEADER( - psa/crypto.h, - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [1], [yes])], - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [0], [no])] - ) + AC_CHECK_HEADER( + psa/crypto.h, + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [0], [no])] + ) AC_CHECK_FUNCS( [ \
@@ -1040,16 +1040,32 @@ [AC_MSG_ERROR([mbed TLS check for AEAD support failed])] ) + AC_CHECK_FUNC( + [mbedtls_ssl_tls_prf], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [0], [no])] + ) + have_export_keying_material="yes" AC_CHECK_FUNC( [mbedtls_ssl_conf_export_keys_ext_cb], - , - [have_export_keying_material="no"] + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [0], [no])] ) + if test "x$ac_cv_func_mbedtls_ssl_conf_export_keys_ext_cb" != xyes; then + AC_CHECK_FUNC( + [mbedtls_ssl_set_export_keys_cb], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [0], [no])] + ) + if test "x$ac_cv_func_mbedtls_ssl_set_export_keys_cb" != xyes; then + have_export_keying_material="no" + fi + fi AC_CHECK_FUNC( [mbedtls_ctr_drbg_update_ret], - AC_DEFINE([HAVE_CTR_DRBG_UPDATE_RET], [1], + AC_DEFINE([HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET], [1], [Use mbedtls_ctr_drbg_update_ret from mbed TLS]), )
src/openvpn/Makefile.am +1 -0
@@ -82,6 +82,7 @@ ovpn_dco_win.h \ platform.c platform.h \ console.c console.h console_builtin.c console_systemd.c \ + mbedtls_compat.h \ mroute.c mroute.h \ mss.c mss.h \ mstats.c mstats.h \
src/openvpn/crypto_mbedtls.c +5 -4
@@ -989,8 +989,9 @@return diff; } -/* mbedtls-2.18.0 or newer */ -#ifdef HAVE_MBEDTLS_SSL_TLS_PRF +/* mbedtls-2.18.0 or newer implements tls_prf, but prf_tls1 is removed +* from recent versions, so we use our own implementation if necessary. */ +#if HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1 )bool ssl_tls1_PRF (const uint8_t *seed,int seed_len,const uint8_t *secret,int secret_len,uint8_t *output,int output_len)
@@ -999,7 +1000,7 @@ secret_len,"" , seed, seed_len, output, output_len)); } -#else /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#else /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ /* * Generate the hash required by for the \c tls1_PRF function. *
@@ -1128,5 +1129,5 @@gc_free (&gc);return true; } -#endif /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#endif /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ #endif /* ENABLE_CRYPTO_MBEDTLS */
src/openvpn/mbedtls_compat.h +8 -5
@@ -33,6 +33,8 @@#ifndef MBEDTLS_COMPAT_H_ #define MBEDTLS_COMPAT_H_ +#include "syshead.h" +#include "errlevel.h" #include <mbedtls/cipher.h>
@@ -41,24 +43,25 @@#include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h> +#include <mbedtls/ssl.h> #include <mbedtls/version.h> #include <mbedtls/x509_crt.h> -#if MBEDTLS_HAVE_PSA_CRYPTO_H +#if HAVE_MBEDTLS_PSA_CRYPTO_H #include <psa/crypto.h> #endif static inline void mbedtls_compat_psa_crypto_init (void ) { -#if MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C ) +#if HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C )if (psa_crypto_init () !=PSA_SUCCESS ) {msg (M_FATAL ,"mbedtls: psa_crypto_init() failed" ); }#else return ; -#endif /* MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ +#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ }/*
@@ -74,14 +77,14 @@ const unsigned char *additional, size_t add_len) { -#if HAVE_CTR_DRBG_UPDATE_RET +#if HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET return mbedtls_ctr_drbg_update_ret (ctx, additional, add_len);#elif MBEDTLS_VERSION_NUMBER <0x03020100 mbedtls_ctr_drbg_update (ctx, additional, add_len);return 0 ;#else return mbedtls_ctr_drbg_update (ctx, additional, add_len); -#endif /* HAVE_CTR_DRBG_UPDATE_RET */ +#endif /* HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET */ } static inline int
src/openvpn/ssl_mbedtls.c +41 -3
75 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e90530726b7f7ba3cee0438f2d81a1ac42e821b
Gerrit-Change-Number: 402
Gerrit-PatchSet: 1
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: MaxF, flichtenheld.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/402?usp=email )
Change subject: Enable key export with mbed TLS 3.x.y
......................................................................
Patch Set 1:
(1 comment)
File src/openvpn/ssl_mbedtls.c:
http://gerrit.openvpn.net/c/openvpn/+/402/comment/0880ba9a_97159dc3 :
PS1, Line 247: msg(M_INFO, "running prf");
Left over debug statement?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e90530726b7f7ba3cee0438f2d81a1ac42e821b
Gerrit-Change-Number: 402
Gerrit-PatchSet: 1
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Sat, 11 Nov 2023 14:26:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: MaxF, flichtenheld.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
to look at the new patch set (#2).
Change subject: Enable key export with mbed TLS 3.x.y
......................................................................
Enable key export with mbed TLS 3.x.y
---
M config.h.cmake.in
M configure.ac
M src/openvpn/Makefile.am
M src/openvpn/crypto_mbedtls.c
M src/openvpn/mbedtls_compat.h
M src/openvpn/ssl_mbedtls.c
6 files changed, 82 insertions(+), 21 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/02/402/2
config.h.cmake.in +4 -1
@@ -387,7 +387,10 @@ #undef HAVE_VSNPRINTF /* we always assume a recent mbed TLS version */ -#define HAVE_CTR_DRBG_UPDATE_RET 1 +#define HAVE_MBEDTLS_PSA_CRYPTO_H 1 +#define HAVE_MBEDTLS_SSL_TLS_PRF 1 +#define HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB 1 +#define HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET 1 /* Path to ifconfig tool */ #define IFCONFIG_PATH "@IFCONFIG_PATH@"
configure.ac +24 -8
@@ -1025,11 +1025,11 @@ [AC_MSG_ERROR([mbed TLS version >= 2.0.0 or >= 3.2.1 required])] ) - AC_CHECK_HEADER( - psa/crypto.h, - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [1], [yes])], - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [0], [no])] - ) + AC_CHECK_HEADER( + psa/crypto.h, + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [0], [no])] + ) AC_CHECK_FUNCS( [ \
@@ -1040,16 +1040,32 @@ [AC_MSG_ERROR([mbed TLS check for AEAD support failed])] ) + AC_CHECK_FUNC( + [mbedtls_ssl_tls_prf], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [0], [no])] + ) + have_export_keying_material="yes" AC_CHECK_FUNC( [mbedtls_ssl_conf_export_keys_ext_cb], - , - [have_export_keying_material="no"] + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [0], [no])] ) + if test "x$ac_cv_func_mbedtls_ssl_conf_export_keys_ext_cb" != xyes; then + AC_CHECK_FUNC( + [mbedtls_ssl_set_export_keys_cb], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [0], [no])] + ) + if test "x$ac_cv_func_mbedtls_ssl_set_export_keys_cb" != xyes; then + have_export_keying_material="no" + fi + fi AC_CHECK_FUNC( [mbedtls_ctr_drbg_update_ret], - AC_DEFINE([HAVE_CTR_DRBG_UPDATE_RET], [1], + AC_DEFINE([HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET], [1], [Use mbedtls_ctr_drbg_update_ret from mbed TLS]), )
src/openvpn/Makefile.am +1 -0
@@ -82,6 +82,7 @@ ovpn_dco_win.h \ platform.c platform.h \ console.c console.h console_builtin.c console_systemd.c \ + mbedtls_compat.h \ mroute.c mroute.h \ mss.c mss.h \ mstats.c mstats.h \
src/openvpn/crypto_mbedtls.c +5 -4
@@ -989,8 +989,9 @@return diff; } -/* mbedtls-2.18.0 or newer */ -#ifdef HAVE_MBEDTLS_SSL_TLS_PRF +/* mbedtls-2.18.0 or newer implements tls_prf, but prf_tls1 is removed +* from recent versions, so we use our own implementation if necessary. */ +#if HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1 )bool ssl_tls1_PRF (const uint8_t *seed,int seed_len,const uint8_t *secret,int secret_len,uint8_t *output,int output_len)
@@ -999,7 +1000,7 @@ secret_len,"" , seed, seed_len, output, output_len)); } -#else /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#else /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ /* * Generate the hash required by for the \c tls1_PRF function. *
@@ -1128,5 +1129,5 @@gc_free (&gc);return true; } -#endif /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#endif /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ #endif /* ENABLE_CRYPTO_MBEDTLS */
src/openvpn/mbedtls_compat.h +8 -5
@@ -33,6 +33,8 @@#ifndef MBEDTLS_COMPAT_H_ #define MBEDTLS_COMPAT_H_ +#include "syshead.h" +#include "errlevel.h" #include <mbedtls/cipher.h>
@@ -41,24 +43,25 @@#include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h> +#include <mbedtls/ssl.h> #include <mbedtls/version.h> #include <mbedtls/x509_crt.h> -#if MBEDTLS_HAVE_PSA_CRYPTO_H +#if HAVE_MBEDTLS_PSA_CRYPTO_H #include <psa/crypto.h> #endif static inline void mbedtls_compat_psa_crypto_init (void ) { -#if MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C ) +#if HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C )if (psa_crypto_init () !=PSA_SUCCESS ) {msg (M_FATAL ,"mbedtls: psa_crypto_init() failed" ); }#else return ; -#endif /* MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ +#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ }/*
@@ -74,14 +77,14 @@ const unsigned char *additional, size_t add_len) { -#if HAVE_CTR_DRBG_UPDATE_RET +#if HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET return mbedtls_ctr_drbg_update_ret (ctx, additional, add_len);#elif MBEDTLS_VERSION_NUMBER <0x03020100 mbedtls_ctr_drbg_update (ctx, additional, add_len);return 0 ;#else return mbedtls_ctr_drbg_update (ctx, additional, add_len); -#endif /* HAVE_CTR_DRBG_UPDATE_RET */ +#endif /* HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET */ } static inline int
src/openvpn/ssl_mbedtls.c +40 -3
68 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e90530726b7f7ba3cee0438f2d81a1ac42e821b
Gerrit-Change-Number: 402
Gerrit-PatchSet: 2
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, plaisthos.
MaxF has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/402?usp=email )
Change subject: Enable key export with mbed TLS 3.x.y
......................................................................
Patch Set 2:
(1 comment)
File src/openvpn/ssl_mbedtls.c:
http://gerrit.openvpn.net/c/openvpn/+/402/comment/981f9692_bec368e8 :
PS1, Line 247: msg(M_INFO, "running prf");
Quoted 1 line
Left over debug statement?
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e90530726b7f7ba3cee0438f2d81a1ac42e821b
Gerrit-Change-Number: 402
Gerrit-PatchSet: 2
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Nov 2023 09:48:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: MaxF, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/402?usp=email )
Change subject: Enable key export with mbed TLS 3.x.y
......................................................................
Patch Set 3: Code-Review-1
(1 comment)
File src/openvpn/ssl_mbedtls.c:
http://gerrit.openvpn.net/c/openvpn/+/402/comment/0824b00d_51b5d999 :
PS3, Line 202: mbedtls_ssl_export_keys_cb(void *p_expkey,
This needs a comment what is going on. The differences between the two variants are way to small to be able to see them easily. So there should be documentation on what they are and why they are necessary. At the very least it should explicitly reference the functions these are used as callback arguments to.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e90530726b7f7ba3cee0438f2d81a1ac42e821b
Gerrit-Change-Number: 402
Gerrit-PatchSet: 3
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Nov 2023 12:13:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: MaxF, flichtenheld, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
to look at the new patch set (#4).
The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld
Change subject: Enable key export with mbed TLS 3.x.y
......................................................................
Enable key export with mbed TLS 3.x.y
---
M config.h.cmake.in
M configure.ac
M src/openvpn/Makefile.am
M src/openvpn/crypto_mbedtls.c
M src/openvpn/mbedtls_compat.h
M src/openvpn/ssl_mbedtls.c
6 files changed, 107 insertions(+), 21 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/02/402/4
config.h.cmake.in +4 -1
@@ -387,7 +387,10 @@ #undef HAVE_VSNPRINTF /* we always assume a recent mbed TLS version */ -#define HAVE_CTR_DRBG_UPDATE_RET 1 +#define HAVE_MBEDTLS_PSA_CRYPTO_H 1 +#define HAVE_MBEDTLS_SSL_TLS_PRF 1 +#define HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB 1 +#define HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET 1 /* Path to ifconfig tool */ #define IFCONFIG_PATH "@IFCONFIG_PATH@"
configure.ac +24 -8
@@ -1025,11 +1025,11 @@ [AC_MSG_ERROR([mbed TLS version >= 2.0.0 or >= 3.2.1 required])] ) - AC_CHECK_HEADER( - psa/crypto.h, - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [1], [yes])], - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [0], [no])] - ) + AC_CHECK_HEADER( + psa/crypto.h, + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [0], [no])] + ) AC_CHECK_FUNCS( [ \
@@ -1040,16 +1040,32 @@ [AC_MSG_ERROR([mbed TLS check for AEAD support failed])] ) + AC_CHECK_FUNC( + [mbedtls_ssl_tls_prf], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [0], [no])] + ) + have_export_keying_material="yes" AC_CHECK_FUNC( [mbedtls_ssl_conf_export_keys_ext_cb], - , - [have_export_keying_material="no"] + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [0], [no])] ) + if test "x$ac_cv_func_mbedtls_ssl_conf_export_keys_ext_cb" != xyes; then + AC_CHECK_FUNC( + [mbedtls_ssl_set_export_keys_cb], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [0], [no])] + ) + if test "x$ac_cv_func_mbedtls_ssl_set_export_keys_cb" != xyes; then + have_export_keying_material="no" + fi + fi AC_CHECK_FUNC( [mbedtls_ctr_drbg_update_ret], - AC_DEFINE([HAVE_CTR_DRBG_UPDATE_RET], [1], + AC_DEFINE([HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET], [1], [Use mbedtls_ctr_drbg_update_ret from mbed TLS]), )
src/openvpn/Makefile.am +1 -0
@@ -82,6 +82,7 @@ ovpn_dco_win.h \ platform.c platform.h \ console.c console.h console_builtin.c console_systemd.c \ + mbedtls_compat.h \ mroute.c mroute.h \ mss.c mss.h \ mstats.c mstats.h \
src/openvpn/crypto_mbedtls.c +5 -4
@@ -989,8 +989,9 @@return diff; } -/* mbedtls-2.18.0 or newer */ -#ifdef HAVE_MBEDTLS_SSL_TLS_PRF +/* mbedtls-2.18.0 or newer implements tls_prf, but prf_tls1 is removed +* from recent versions, so we use our own implementation if necessary. */ +#if HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1 )bool ssl_tls1_PRF (const uint8_t *seed,int seed_len,const uint8_t *secret,int secret_len,uint8_t *output,int output_len)
@@ -999,7 +1000,7 @@ secret_len,"" , seed, seed_len, output, output_len)); } -#else /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#else /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ /* * Generate the hash required by for the \c tls1_PRF function. *
@@ -1128,5 +1129,5 @@gc_free (&gc);return true; } -#endif /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#endif /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ #endif /* ENABLE_CRYPTO_MBEDTLS */
src/openvpn/mbedtls_compat.h +8 -5
@@ -33,6 +33,8 @@#ifndef MBEDTLS_COMPAT_H_ #define MBEDTLS_COMPAT_H_ +#include "syshead.h" +#include "errlevel.h" #include <mbedtls/cipher.h>
@@ -41,24 +43,25 @@#include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h> +#include <mbedtls/ssl.h> #include <mbedtls/version.h> #include <mbedtls/x509_crt.h> -#if MBEDTLS_HAVE_PSA_CRYPTO_H +#if HAVE_MBEDTLS_PSA_CRYPTO_H #include <psa/crypto.h> #endif static inline void mbedtls_compat_psa_crypto_init (void ) { -#if MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C ) +#if HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C )if (psa_crypto_init () !=PSA_SUCCESS ) {msg (M_FATAL ,"mbedtls: psa_crypto_init() failed" ); }#else return ; -#endif /* MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ +#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ }/*
@@ -74,14 +77,14 @@ const unsigned char *additional, size_t add_len) { -#if HAVE_CTR_DRBG_UPDATE_RET +#if HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET return mbedtls_ctr_drbg_update_ret (ctx, additional, add_len);#elif MBEDTLS_VERSION_NUMBER <0x03020100 mbedtls_ctr_drbg_update (ctx, additional, add_len);return 0 ;#else return mbedtls_ctr_drbg_update (ctx, additional, add_len); -#endif /* HAVE_CTR_DRBG_UPDATE_RET */ +#endif /* HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET */ } static inline int
src/openvpn/ssl_mbedtls.c +65 -3
93 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e90530726b7f7ba3cee0438f2d81a1ac42e821b
Gerrit-Change-Number: 402
Gerrit-PatchSet: 4
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, plaisthos.
MaxF has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/402?usp=email )
Change subject: Enable key export with mbed TLS 3.x.y
......................................................................
Patch Set 4:
(1 comment)
File src/openvpn/ssl_mbedtls.c:
http://gerrit.openvpn.net/c/openvpn/+/402/comment/27adbd58_9c88f0d9 :
PS3, Line 202: mbedtls_ssl_export_keys_cb(void *p_expkey,
Quoted 1 line
This needs a comment what is going on. […]
I added some comments, let me know what you think.
Also, I made it a fatal error when we get an unexpected secret_len, because for TLS 1.2, it's a fixed size and if it's different something must have gone very wrong.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e90530726b7f7ba3cee0438f2d81a1ac42e821b
Gerrit-Change-Number: 402
Gerrit-PatchSet: 4
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Nov 2023 16:35:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: MaxF, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/402?usp=email )
Change subject: Enable key export with mbed TLS 3.x.y
......................................................................
Patch Set 5: Code-Review+2
(1 comment)
File src/openvpn/ssl_mbedtls.c:
http://gerrit.openvpn.net/c/openvpn/+/402/comment/e14af5ff_f0c5c3b5 :
PS3, Line 202: mbedtls_ssl_export_keys_cb(void *p_expkey,
Quoted 1 line
I added some comments, let me know what you think. […]
Acknowledged
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e90530726b7f7ba3cee0438f2d81a1ac42e821b
Gerrit-Change-Number: 402
Gerrit-PatchSet: 5
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Wed, 15 Nov 2023 17:17:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: MaxF <[email protected]...>
Gerrit-MessageType: comment
PATCH v5 1/1 Enable key export with mbed TLS 3.x.y
In reply to a message not in the archiveFrom: Max Fillinger <[email protected]...>
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/402
This mail reflects revision 5 of this Change. Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>
config.h.cmake.in +4 -1
@@ -387,7 +387,10 @@ #undef HAVE_VSNPRINTF /* we always assume a recent mbed TLS version */ -#define HAVE_CTR_DRBG_UPDATE_RET 1 +#define HAVE_MBEDTLS_PSA_CRYPTO_H 1 +#define HAVE_MBEDTLS_SSL_TLS_PRF 1 +#define HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB 1 +#define HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET 1 /* Path to ifconfig tool */ #define IFCONFIG_PATH "@IFCONFIG_PATH@"
configure.ac +24 -8
@@ -1025,11 +1025,11 @@ [AC_MSG_ERROR([mbed TLS version >= 2.0.0 or >= 3.2.1 required])] ) - AC_CHECK_HEADER( - psa/crypto.h, - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [1], [yes])], - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [0], [no])] - ) + AC_CHECK_HEADER( + psa/crypto.h, + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [0], [no])] + ) AC_CHECK_FUNCS( [ \
@@ -1040,16 +1040,32 @@ [AC_MSG_ERROR([mbed TLS check for AEAD support failed])] ) + AC_CHECK_FUNC( + [mbedtls_ssl_tls_prf], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [0], [no])] + ) + have_export_keying_material="yes" AC_CHECK_FUNC( [mbedtls_ssl_conf_export_keys_ext_cb], - , - [have_export_keying_material="no"] + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [0], [no])] ) + if test "x$ac_cv_func_mbedtls_ssl_conf_export_keys_ext_cb" != xyes; then + AC_CHECK_FUNC( + [mbedtls_ssl_set_export_keys_cb], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [0], [no])] + ) + if test "x$ac_cv_func_mbedtls_ssl_set_export_keys_cb" != xyes; then + have_export_keying_material="no" + fi + fi AC_CHECK_FUNC( [mbedtls_ctr_drbg_update_ret], - AC_DEFINE([HAVE_CTR_DRBG_UPDATE_RET], [1], + AC_DEFINE([HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET], [1], [Use mbedtls_ctr_drbg_update_ret from mbed TLS]), )
src/openvpn/Makefile.am +1 -0
@@ -82,6 +82,7 @@ ovpn_dco_win.h \ platform.c platform.h \ console.c console.h console_builtin.c console_systemd.c \ + mbedtls_compat.h \ mroute.c mroute.h \ mss.c mss.h \ mstats.c mstats.h \
src/openvpn/crypto_mbedtls.c +5 -4
@@ -989,8 +989,9 @@return diff; } -/* mbedtls-2.18.0 or newer */ -#ifdef HAVE_MBEDTLS_SSL_TLS_PRF +/* mbedtls-2.18.0 or newer implements tls_prf, but prf_tls1 is removed +* from recent versions, so we use our own implementation if necessary. */ +#if HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1 )bool ssl_tls1_PRF (const uint8_t *seed,int seed_len,const uint8_t *secret,int secret_len,uint8_t *output,int output_len)
@@ -999,7 +1000,7 @@ secret_len,"" , seed, seed_len, output, output_len)); } -#else /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#else /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ /* * Generate the hash required by for the \c tls1_PRF function. *
@@ -1128,5 +1129,5 @@gc_free (&gc);return true; } -#endif /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#endif /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ #endif /* ENABLE_CRYPTO_MBEDTLS */
src/openvpn/mbedtls_compat.h +8 -5
@@ -33,6 +33,8 @@#ifndef MBEDTLS_COMPAT_H_ #define MBEDTLS_COMPAT_H_ +#include "syshead.h" +#include "errlevel.h" #include <mbedtls/cipher.h>
@@ -41,24 +43,25 @@#include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h> +#include <mbedtls/ssl.h> #include <mbedtls/version.h> #include <mbedtls/x509_crt.h> -#if MBEDTLS_HAVE_PSA_CRYPTO_H +#if HAVE_MBEDTLS_PSA_CRYPTO_H #include <psa/crypto.h> #endif static inline void mbedtls_compat_psa_crypto_init (void ) { -#if MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C ) +#if HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C )if (psa_crypto_init () !=PSA_SUCCESS ) {msg (M_FATAL ,"mbedtls: psa_crypto_init() failed" ); }#else return ; -#endif /* MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ +#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ }/*
@@ -74,14 +77,14 @@ const unsigned char *additional, size_t add_len) { -#if HAVE_CTR_DRBG_UPDATE_RET +#if HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET return mbedtls_ctr_drbg_update_ret (ctx, additional, add_len);#elif MBEDTLS_VERSION_NUMBER <0x03020100 mbedtls_ctr_drbg_update (ctx, additional, add_len);return 0 ;#else return mbedtls_ctr_drbg_update (ctx, additional, add_len); -#endif /* HAVE_CTR_DRBG_UPDATE_RET */ +#endif /* HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET */ } static inline int
src/openvpn/ssl_mbedtls.c +65 -3
93 lines not on this page · raw message
[Openvpn-devel] [PATCH applied] Re: Enable key export with mbed TLS 3.x.y
Only tested compilation across the mbedtls versions in the GHA builds.
Your patch has been applied to the master branch.
commit b5faf1b2e90fd44c5137a2b8f3da98c7ae482fc1 (master)
Author: Max Fillinger Date: Fri Nov 17 10:14:01 2023 +0100
Enable key export with mbed TLS 3.x.y
Signed-off-by: Max Fillinger <[email protected]...>
Acked-by: Frank Lichtenheld <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27458.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#6) to the change originally created by MaxF. ( http://gerrit.openvpn.net/c/openvpn/+/402?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld
Change subject: Enable key export with mbed TLS 3.x.y
......................................................................
Enable key export with mbed TLS 3.x.y
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27458.html
---
M config.h.cmake.in
M configure.ac
M src/openvpn/Makefile.am
M src/openvpn/crypto_mbedtls.c
M src/openvpn/mbedtls_compat.h
M src/openvpn/ssl_mbedtls.c
6 files changed, 107 insertions(+), 21 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/02/402/6
config.h.cmake.in +4 -1
@@ -387,7 +387,10 @@ #undef HAVE_VSNPRINTF /* we always assume a recent mbed TLS version */ -#define HAVE_CTR_DRBG_UPDATE_RET 1 +#define HAVE_MBEDTLS_PSA_CRYPTO_H 1 +#define HAVE_MBEDTLS_SSL_TLS_PRF 1 +#define HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB 1 +#define HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET 1 /* Path to ifconfig tool */ #define IFCONFIG_PATH "@IFCONFIG_PATH@"
configure.ac +24 -8
@@ -1025,11 +1025,11 @@ [AC_MSG_ERROR([mbed TLS version >= 2.0.0 or >= 3.2.1 required])] ) - AC_CHECK_HEADER( - psa/crypto.h, - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [1], [yes])], - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [0], [no])] - ) + AC_CHECK_HEADER( + psa/crypto.h, + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [0], [no])] + ) AC_CHECK_FUNCS( [ \
@@ -1040,16 +1040,32 @@ [AC_MSG_ERROR([mbed TLS check for AEAD support failed])] ) + AC_CHECK_FUNC( + [mbedtls_ssl_tls_prf], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [0], [no])] + ) + have_export_keying_material="yes" AC_CHECK_FUNC( [mbedtls_ssl_conf_export_keys_ext_cb], - , - [have_export_keying_material="no"] + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [0], [no])] ) + if test "x$ac_cv_func_mbedtls_ssl_conf_export_keys_ext_cb" != xyes; then + AC_CHECK_FUNC( + [mbedtls_ssl_set_export_keys_cb], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [0], [no])] + ) + if test "x$ac_cv_func_mbedtls_ssl_set_export_keys_cb" != xyes; then + have_export_keying_material="no" + fi + fi AC_CHECK_FUNC( [mbedtls_ctr_drbg_update_ret], - AC_DEFINE([HAVE_CTR_DRBG_UPDATE_RET], [1], + AC_DEFINE([HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET], [1], [Use mbedtls_ctr_drbg_update_ret from mbed TLS]), )
src/openvpn/Makefile.am +1 -0
@@ -82,6 +82,7 @@ ovpn_dco_win.h \ platform.c platform.h \ console.c console.h console_builtin.c console_systemd.c \ + mbedtls_compat.h \ mroute.c mroute.h \ mss.c mss.h \ mstats.c mstats.h \
src/openvpn/crypto_mbedtls.c +5 -4
@@ -989,8 +989,9 @@return diff; } -/* mbedtls-2.18.0 or newer */ -#ifdef HAVE_MBEDTLS_SSL_TLS_PRF +/* mbedtls-2.18.0 or newer implements tls_prf, but prf_tls1 is removed +* from recent versions, so we use our own implementation if necessary. */ +#if HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1 )bool ssl_tls1_PRF (const uint8_t *seed,int seed_len,const uint8_t *secret,int secret_len,uint8_t *output,int output_len)
@@ -999,7 +1000,7 @@ secret_len,"" , seed, seed_len, output, output_len)); } -#else /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#else /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ /* * Generate the hash required by for the \c tls1_PRF function. *
@@ -1128,5 +1129,5 @@gc_free (&gc);return true; } -#endif /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#endif /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ #endif /* ENABLE_CRYPTO_MBEDTLS */
src/openvpn/mbedtls_compat.h +8 -5
@@ -33,6 +33,8 @@#ifndef MBEDTLS_COMPAT_H_ #define MBEDTLS_COMPAT_H_ +#include "syshead.h" +#include "errlevel.h" #include <mbedtls/cipher.h>
@@ -41,24 +43,25 @@#include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h> +#include <mbedtls/ssl.h> #include <mbedtls/version.h> #include <mbedtls/x509_crt.h> -#if MBEDTLS_HAVE_PSA_CRYPTO_H +#if HAVE_MBEDTLS_PSA_CRYPTO_H #include <psa/crypto.h> #endif static inline void mbedtls_compat_psa_crypto_init (void ) { -#if MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C ) +#if HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C )if (psa_crypto_init () !=PSA_SUCCESS ) {msg (M_FATAL ,"mbedtls: psa_crypto_init() failed" ); }#else return ; -#endif /* MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ +#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ }/*
@@ -74,14 +77,14 @@ const unsigned char *additional, size_t add_len) { -#if HAVE_CTR_DRBG_UPDATE_RET +#if HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET return mbedtls_ctr_drbg_update_ret (ctx, additional, add_len);#elif MBEDTLS_VERSION_NUMBER <0x03020100 mbedtls_ctr_drbg_update (ctx, additional, add_len);return 0 ;#else return mbedtls_ctr_drbg_update (ctx, additional, add_len); -#endif /* HAVE_CTR_DRBG_UPDATE_RET */ +#endif /* HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET */ } static inline int
src/openvpn/ssl_mbedtls.c +65 -3
93 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e90530726b7f7ba3cee0438f2d81a1ac42e821b
Gerrit-Change-Number: 402
Gerrit-PatchSet: 6
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/402?usp=email )
Change subject: Enable key export with mbed TLS 3.x.y
......................................................................
Enable key export with mbed TLS 3.x.y
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27458.html
---
M config.h.cmake.in
M configure.ac
M src/openvpn/Makefile.am
M src/openvpn/crypto_mbedtls.c
M src/openvpn/mbedtls_compat.h
M src/openvpn/ssl_mbedtls.c
6 files changed, 107 insertions(+), 21 deletions(-)
config.h.cmake.in +4 -1
@@ -387,7 +387,10 @@ #undef HAVE_VSNPRINTF /* we always assume a recent mbed TLS version */ -#define HAVE_CTR_DRBG_UPDATE_RET 1 +#define HAVE_MBEDTLS_PSA_CRYPTO_H 1 +#define HAVE_MBEDTLS_SSL_TLS_PRF 1 +#define HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB 1 +#define HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET 1 /* Path to ifconfig tool */ #define IFCONFIG_PATH "@IFCONFIG_PATH@"
configure.ac +24 -8
@@ -1025,11 +1025,11 @@ [AC_MSG_ERROR([mbed TLS version >= 2.0.0 or >= 3.2.1 required])] ) - AC_CHECK_HEADER( - psa/crypto.h, - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [1], [yes])], - [AC_DEFINE([MBEDTLS_HAVE_PSA_CRYPTO_H], [0], [no])] - ) + AC_CHECK_HEADER( + psa/crypto.h, + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [0], [no])] + ) AC_CHECK_FUNCS( [ \
@@ -1040,16 +1040,32 @@ [AC_MSG_ERROR([mbed TLS check for AEAD support failed])] ) + AC_CHECK_FUNC( + [mbedtls_ssl_tls_prf], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [0], [no])] + ) + have_export_keying_material="yes" AC_CHECK_FUNC( [mbedtls_ssl_conf_export_keys_ext_cb], - , - [have_export_keying_material="no"] + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [0], [no])] ) + if test "x$ac_cv_func_mbedtls_ssl_conf_export_keys_ext_cb" != xyes; then + AC_CHECK_FUNC( + [mbedtls_ssl_set_export_keys_cb], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [0], [no])] + ) + if test "x$ac_cv_func_mbedtls_ssl_set_export_keys_cb" != xyes; then + have_export_keying_material="no" + fi + fi AC_CHECK_FUNC( [mbedtls_ctr_drbg_update_ret], - AC_DEFINE([HAVE_CTR_DRBG_UPDATE_RET], [1], + AC_DEFINE([HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET], [1], [Use mbedtls_ctr_drbg_update_ret from mbed TLS]), )
src/openvpn/Makefile.am +1 -0
@@ -82,6 +82,7 @@ ovpn_dco_win.h \ platform.c platform.h \ console.c console.h console_builtin.c console_systemd.c \ + mbedtls_compat.h \ mroute.c mroute.h \ mss.c mss.h \ mstats.c mstats.h \
src/openvpn/crypto_mbedtls.c +5 -4
@@ -989,8 +989,9 @@return diff; } -/* mbedtls-2.18.0 or newer */ -#ifdef HAVE_MBEDTLS_SSL_TLS_PRF +/* mbedtls-2.18.0 or newer implements tls_prf, but prf_tls1 is removed +* from recent versions, so we use our own implementation if necessary. */ +#if HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1 )bool ssl_tls1_PRF (const uint8_t *seed,int seed_len,const uint8_t *secret,int secret_len,uint8_t *output,int output_len)
@@ -999,7 +1000,7 @@ secret_len,"" , seed, seed_len, output, output_len)); } -#else /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#else /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ /* * Generate the hash required by for the \c tls1_PRF function. *
@@ -1128,5 +1129,5 @@gc_free (&gc);return true; } -#endif /* ifdef HAVE_MBEDTLS_SSL_TLS_PRF */ +#endif /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ #endif /* ENABLE_CRYPTO_MBEDTLS */
src/openvpn/mbedtls_compat.h +8 -5
@@ -33,6 +33,8 @@#ifndef MBEDTLS_COMPAT_H_ #define MBEDTLS_COMPAT_H_ +#include "syshead.h" +#include "errlevel.h" #include <mbedtls/cipher.h>
@@ -41,24 +43,25 @@#include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h> +#include <mbedtls/ssl.h> #include <mbedtls/version.h> #include <mbedtls/x509_crt.h> -#if MBEDTLS_HAVE_PSA_CRYPTO_H +#if HAVE_MBEDTLS_PSA_CRYPTO_H #include <psa/crypto.h> #endif static inline void mbedtls_compat_psa_crypto_init (void ) { -#if MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C ) +#if HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C )if (psa_crypto_init () !=PSA_SUCCESS ) {msg (M_FATAL ,"mbedtls: psa_crypto_init() failed" ); }#else return ; -#endif /* MBEDTLS_HAVE_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ +#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ }/*
@@ -74,14 +77,14 @@ const unsigned char *additional, size_t add_len) { -#if HAVE_CTR_DRBG_UPDATE_RET +#if HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET return mbedtls_ctr_drbg_update_ret (ctx, additional, add_len);#elif MBEDTLS_VERSION_NUMBER <0x03020100 mbedtls_ctr_drbg_update (ctx, additional, add_len);return 0 ;#else return mbedtls_ctr_drbg_update (ctx, additional, add_len); -#endif /* HAVE_CTR_DRBG_UPDATE_RET */ +#endif /* HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET */ } static inline int
src/openvpn/ssl_mbedtls.c +65 -3
93 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/402?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e90530726b7f7ba3cee0438f2d81a1ac42e821b
Gerrit-Change-Number: 402
Gerrit-PatchSet: 6
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged